<?php

// No direct access

defined('_JEXEC') or die('Restricted access');

$document = &JFactory::getDocument();

//load OpenLayers
$document->addScript('http://www.openlayers.org/api/OpenLayers.js');
//load OpenStreetMap & Yahoo maps
$document->addScript('http://www.openstreetmap.org/openlayers/OpenStreetMap.js');
$document->addScript('http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers');

//load custom map
//$document->addScript(JPATH_COMPONENT.DS.'views'.DS.'worldmap'.DS.'tmpl'.DS.'worldmap.js');

?>
<h1>
    <?php
    /* DEBUG ONLY
    $mrk = $this->markers;
    print_r($mrk);
    */
    ?>
</h1>

<center>
    <div id="map" style="width:maincolumn.width; height:500px; align:center;" align="center">
    </div>
</center>
<!--
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=euzuro-openlayers"></script>
-->
<script>
    var map, layer;
    OpenLayers.ProxyHost="/proxy/?url=";
    map = new OpenLayers.Map('map');
    /*var map = new OpenLayers.Map ("map", {
                  controls:[
                      new OpenLayers.Control.Navigation(),
                      new OpenLayers.Control.PanZoomBar(),
                      new OpenLayers.Control.LayerSwitcher(),
                      new OpenLayers.Control.Attribution()],
                  maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
                  maxResolution: 156543.0399,
                  numZoomLevels: 19,
                  units: 'm',
                  projection: new OpenLayers.Projection("EPSG:900913"),
                  displayProjection: new OpenLayers.Projection("EPSG:4326")
              } );*/


    layer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {
        layers: 'basic'
    } );


    map.addLayer(layer);
    /*
              var layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {layers: 'basic'});
              map.addLayer(layerTilesAtHome);

              var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
              map.addLayer(mapnik);
     */
    var yahoo = new OpenLayers.Layer.Yahoo(
    "Yahoo Street",
    {
        'sphericalMercator': false
    }
);
    map.addLayer(yahoo);

    //var newl = new OpenLayers.Layer.Text( "Posizioni GNU", {location: "./positions.txt"} );
    var newl = new OpenLayers.Layer.Text( "Posizioni GNU", {
        location: "PositionsQuery.php"
    } );
    map.addLayer(newl);

    map.addControl(new OpenLayers.Control.LayerSwitcher());
    //map.zoomToMaxExtent();

    var lat=44.085001;
    var lon=12.398817;
    var zoom=3;
    var lonLat = new OpenLayers.LonLat(lon, lat).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject());

    map.setCenter (lonLat, zoom);
</script>


